package com.sugon.stream;

import java.util.stream.LongStream;

public class TestStream_parallel {

	public static void main(String[] args) {
		int n = 1000000; 
		
		LongStream stream =LongStream.rangeClosed(1, n);
		
		long t1 = System.nanoTime();
		long result = stream.sum();
		
		long t2 = System.nanoTime();
		System.out.println((t2-t1)/1E9);
		
		
		LongStream stream2 = LongStream.rangeClosed(1,n);
		t1 = System.nanoTime();
		
		stream2 = stream2.parallel();
		result = stream2.sum();
		
		t2 = System.nanoTime();
		System.out.println((t2-t1)/1E9);
		
	}

}
